//
//  NYIPAHeadReusableView.m
//  NiuWaJiaoYu
//
//  Created by MinLison on 2018/2/4.
//  Copyright © 2018年 niuwaketang. All rights reserved.
//

#import "NYIPAHeadReusableView.h"

@interface NYIPAHeadReusableView ()

@property (nonatomic, strong) UILabel *numLabel;
@property (nonatomic, strong) UILabel *remainLabel;
@property (nonatomic, strong) UILabel *titleLabel;

@end

@implementation NYIPAHeadReusableView

#pragma mark - Intial Methods
- (void)setupView {
    [super setupView];
    
    [self addSubview:self.numLabel];
    [self addSubview:self.remainLabel];

    [self addSubview:self.titleLabel];
    
    [self.numLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(self);
        make.centerY.equalTo(self).offset(-20);
        make.height.mas_equalTo(40);
        make.left.equalTo(self).offset(20);
        make.right.equalTo(self).offset(-20);
    }];
    [self.remainLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.right.equalTo(self);
        make.top.equalTo(self.numLabel.mas_bottom).offset(5);
        make.height.mas_equalTo(17);
    }];

    [self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self).offset(20);
        make.bottom.equalTo(self);
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(120);
    }];
}
#pragma mark - Setter Getter Methods
- (void)setTheNumText:(NSString *)numText {
    _numLabel.text = numText;
}
- (UILabel *)numLabel {
    if (!_numLabel) {
        _numLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        NSString *path = [[NSBundle mainBundle] pathForResource:@"DINMittelschrift_PWSH" ofType:@"ttf"];
        _numLabel.font = [self getcCustomFontPath:path withFontSize:38];
        _numLabel.textAlignment = NSTextAlignmentCenter;
        _numLabel.textColor = UIColorMakeWithHex(@"#333333");
    }
    return _numLabel;
}
- (UILabel *)remainLabel {
    if (!_remainLabel) {
        _remainLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        _remainLabel.font = UIFontMake(14);
        _remainLabel.textAlignment = NSTextAlignmentCenter;
        _remainLabel.text = @"剩余牛币";
        _remainLabel.textColor = UIColorMakeWithHex(@"#999999");
    }
    return _remainLabel;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        _titleLabel.font = UIFontMake(15);
        _titleLabel.textAlignment = NSTextAlignmentLeft;
        _titleLabel.text = @"请选择充值牛币";
        _titleLabel.textColor = UIColorMakeWithHex(@"#333333");
    }
    return _titleLabel;
}

//MARK: -获取字体路径
- (UIFont*)getcCustomFontPath:(NSString*)path withFontSize:(CGFloat)fontSize {
    
    NSURL *fontUrl = [NSURL fileURLWithPath:path];
    CGDataProviderRef fontDataProvider = CGDataProviderCreateWithURL((__bridge CFURLRef)fontUrl);
    CGFontRef fontRef = CGFontCreateWithDataProvider(fontDataProvider);
    CGDataProviderRelease(fontDataProvider);
    CTFontManagerRegisterGraphicsFont(fontRef, NULL);
    NSString *fontName = CFBridgingRelease(CGFontCopyPostScriptName(fontRef));
    UIFont *font = [UIFont fontWithName:fontName size:fontSize];
    CGFontRelease(fontRef);
    return font;
}


@end
